package xmltest;

import java.io.File;
import java.util.Iterator;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class PhoneTest {
	public static void main(String[] args) {
		PhoneTest.showPhoneInfo();
	}

	public static void showPhoneInfo() {
		Document doc = null;
		try {
			SAXReader saxReader = new SAXReader();
			doc = saxReader.read(new File(
					"D:\\Java编程语言基础\\第1章\\ADV第6章案例\\Phone.xml"));
		} catch (Exception e) {
			e.printStackTrace();
		}
		Element root = doc.getRootElement();
		for (Iterator itBrand = root.elementIterator(); itBrand.hasNext();) {
			Element brand = (Element) itBrand.next();
			System.out.println("品牌:" + brand.attributeValue("name"));
			for (Iterator itType = brand.elementIterator(); itType.hasNext();) {
				Element type = (Element) itType.next();
				System.out.println("\tͺ型号:" + type.attributeValue("name"));
			}
		}

	}
}